using System;
using AltDotNetSe.Repositories;
using Castle.MonoRail.Framework;
using AltDotNetSe.Models;

namespace AltDotNetSe.Controllers
{
    public class PageController : SmartDispatcherController
    {
        private readonly IPageRepository repository;

        public PageController(IPageRepository repository)
        {
            this.repository = repository;
        }

        public PageController()
        {
            repository = new ActiveRecordPageRepository();
        }
        public void Show(string title)
        {
            Page page = repository.RetrievePage(title);
            PropertyBag["page"] = page;
        }

        public void Add(string title, string text)
        {
            repository.Store(new Page(title, text));
        }

        public void CreatePage()
        {}
    }
}